package org.example.buysystem.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.example.buysystem.service.AvatarService;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/avatar")
@CrossOrigin
@Api(value = "头像",tags = {"头像接口"})
public class AvatarController {

    private final AvatarService avatarService;

    public AvatarController(AvatarService avatarService) {
        this.avatarService = avatarService;
    }

    @GetMapping("/{fileName}")
    @ApiOperation(value = "获取头像",notes = "根据文件名获取头像")
    public String downloadAvatar(@PathVariable String fileName, HttpServletResponse response){
        avatarService.downloadAvatar(fileName,response);

        return "success";
    }

}
